<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

	<h:head>
	
	

	
	</h:head>
	
	<h:body > 
	<p:dialog header="Faça seu Cadastro" id="dialog" minWidth="400"
	width="450" height="500" modal="true" closable="false" position="center"
	showEffect="slide" draggable="true" resizable="false" visible="true">
		<h:form id="cadastrar">
		 <p:messages id="messages" />
		  <p:panelGrid columns="2" cellpadding="10" width="400" >
		   <p:outputLabel for="nome" value="Nome:" />
		   <p:inputText id="nome" value="#{UsuarioMB.usuario.nome}" required="true" validatorMessage="Escrava seu nome corretamente!">
		   <f:validateRegex pattern="^[aA-zZ]+((\s[aA-zZ]+)+)?$"/>
		   </p:inputText>
		   
		   <p:outputLabel for="email" value="Email:" />
		   <p:inputText id="email" value="#{UsuarioMB.usuario.email}" required="true" validatorMessage="Email Invalido, entre com o email correto!">
		   <f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$" />
		   </p:inputText>
		   		   
		   <p:outputLabel for="senha" value="Senha:" />
		   <p:password id="senha" value="#{UsuarioMB.usuario.senha}" required="true" match="confirmarsenha" validatorMessage="Erro na confirmação da senha!" 
		   feedback="true" promptLabel="Entre com a senha" weakLabel="Fraca" goodLabel="Boa" strongLabel="Forte"/>
		   
		   <p:outputLabel for="confirmarsenha" value="Confirmar Senha:" />
		   <p:password id="confirmarsenha" required="true" value="#{UsuarioMB.usuario.senha}"
		   feedback="true" promptLabel="Entre com a senha" weakLabel="Fraca" goodLabel="Boa" strongLabel="Forte" />
		   
		   <p:outputLabel for="console" value="Descrição:" />
		   <p:selectOneMenu id="console" value="#{UsuarioMB.usuario.descricao}" style="width:125px">
            <f:selectItem itemLabel="Estudante" itemValue="Estudante" />
            <f:selectItem itemLabel="Professor" itemValue="Professor" />
            <f:selectItem itemLabel="Outros" itemValue="Outros" />
           </p:selectOneMenu>
      
         

	  </p:panelGrid>
	   <h:panelGrid columns="3" cellspacing="5" cellpadding="4">
		   <p:commandButton value="Cadastrar" icon="ui-icon-star"  action="#{UsuarioMB.cadastraUsuario}" update="messages" ajax="false" />
		  
		   
		  	 <p:commandButton value="Limpar" type="reset" immediate="true"/>
		    <p:commandButton value="Cancelar" ajax="false" immediate="true" action="Index2.xhtml"  />
		  
		  
		  	 </h:panelGrid>
		  	
		
	   
		</h:form>

	</p:dialog>
	</h:body>


</html>